﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace CodeContrib.Web.Mvc
{
	[Serializable]
	public class InformationMessageDictionary : Dictionary<string, Collection<string>>
	{
		public IEnumerable<string> InformationMessages
		{
			get { return Values.SelectMany(x => x); }
		}

		public void AddInformationMessage(string key, string informationMessage, params object[] args)
		{
			Guard.NotNull(key, "key");

			Collection<string> informationMessages;

			if (!TryGetValue(key, out informationMessages))
			{
				informationMessages = new Collection<string>();
			}

			informationMessages.Add(string.Format(informationMessage, args));
		}
	}
}